package com.shibaobei.activity.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.shibaobei.activity.dao.UserMapper;
import com.shibaobei.activity.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2020/4/28 0028.
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public JSON login(User user,HttpSession session){
        JSONObject json = new JSONObject();
        User  u = userMapper.findUser(user);
        if(u.getPassword().equals(user.getPassword())){
            json.put("id",u.getId());
            json.put("name",u.getName());
            session.setAttribute("user",u);
        }
        return json;
    }

}
